import { request } from "../../request/index.js"
import regeneratorRuntime from "../../lib/runtime/runtime"

Page({

  /**
   * 页面的初始数据
   */
  data: {
    auther: {
      id: 0,
      head: 'https://i2.hdslb.com/bfs/face/cb048764be6e075d1a3e01bd8bdf99a653f3adfe.jpg@150w_150h.jpg',
      auther: '木上野狐',
      text: '虽然在赛后第一时间发布了变化图，但始终不敢做这局棋的复盘。\n不知不觉来到了两个月后。\n慢慢发觉：宝剑锋从磨砺出。\n人生不可能事事如意，挫折与失望，本就是棋与人生的一部分。\n希望柯洁早日拿到第九冠，重归王座！',
      zan: 0,
      liuyan: 0,
      time: '2021-2-2 22:42:42',
      img: [
        'https://i0.hdslb.com/bfs/archive/51582cc37041ea7bf004d19ab022053ecbc939ff.jpg@206w_116h_1c_100q.jpg',
      ],
      personal: '你也不过如此',
    },
    reply: [{
      id: 0,
      head: 'https://i2.hdslb.com/bfs/face/cb048764be6e075d1a3e01bd8bdf99a653f3adfe.jpg@150w_150h.jpg',
      auther: '木上野狐',
      text: '复与洁早日拿到第九冠，重归王座！',
      zan: 0,
      liuyan: 0,
      time: '2021-2-2 22:42:42',
      img: []
    }, {
      id: 1,
      head: 'https://i2.hdslb.com/bfs/face/cb048764be6e075d1a3e01bd8bdf99a653f3adfe.jpg@150w_150h.jpg',
      auther: '木上野狐',
      text: '虽然在赛后第一时间发布了变化图，但始终不敢做这局棋的复盘。\n不知不觉来到了两个月后。\n慢慢发觉：宝剑锋从磨砺出。\n人生不可能事事如意，挫折与失望，本就是棋与人生的一部分。\n希望柯洁早日拿到第九冠，重归王座！',
      zan: 0,
      liuyan: 0,
      time: '2021-2-2 22:42:42',
      img: [
        'https://i0.hdslb.com/bfs/album/9b321df73f2108d20dbde13504d5e311388206c6.jpg@518w.webp',
      ],
      reply2: [{
        id: 0,
        zan: 0,
        head: 'https://i2.hdslb.com/bfs/face/cb048764be6e075d1a3e01bd8bdf99a653f3adfe.jpg@150w_150h.jpg',
        target: '木上野狐',
        auther: '柳江南',
        text: 'WDNDNMD',
        img: 'https://i0.hdslb.com/bfs/album/9b321df73f2108d20dbde13504d5e311388206c6.jpg@518w.webp'
      }, {
        id: 1,
        zan: 0,
        head: 'https://i2.hdslb.com/bfs/face/cb048764be6e075d1a3e01bd8bdf99a653f3adfe.jpg@150w_150h.jpg',
        target: '木上野狐',
        auther: '柳江南',
        text: 'WDNMDWDNMDWDNMDWDNMDWDNMDWDNMDWDNMDWDNMDWDNMDWDNMDWDNMD',
        img: ''
      }, {
        id: 2,
        zan: 0,
        head: 'https://i2.hdslb.com/bfs/face/cb048764be6e075d1a3e01bd8bdf99a653f3adfe.jpg@150w_150h.jpg',
        target: '木上野狐',
        auther: 'aaa',
        text: 'WDNMDWDNMDWDNMDWDNMDWDNMDWDNMDWDNMDWDNMDWDNMDWDNMDWDNMD',
        img: ''
      }]
    }, {
      id: 2,
      head: 'https://i2.hdslb.com/bfs/face/cb048764be6e075d1a3e01bd8bdf99a653f3adfe.jpg@150w_150h.jpg',
      auther: '木上野狐',
      text: '虽然在赛后第一时间发布了变化图，但始终不敢做这局棋的复盘。\n不知不觉来到了两个月后。\n慢慢发觉：宝剑锋从磨砺出。\n人生不可能事事如意，挫折与失望，本就是棋与人生的一部分。\n希望柯洁早日拿到第九冠，重归王座！',
      zan: 0,
      liuyan: 0,
      time: '2021-2-2 22:42:42',
      img: []
    }]
  },

  
  onLoad: function (options) {
    let pageid = options.pageid
    console.log(pageid)
    this.getAuther()
    this.getReply(pageid)
  },

  getAuther() {
    let auther = wx.getStorageSync('page')
    // console.log(auther)
    this.setData({
      auther
    })
  },

  async getReply(pageid) {
    let res = await request({
      url: "http://localhost:3000/getpagedetail/" + pageid
    })
    this.setData({
      reply: res
    })
  },

  preview(e) {
    // urls 获取 park 里的所有图片url
    // current 获取当前点击图片url
    const current = e.currentTarget.dataset.url
    wx.previewImage({
      current: current,
      urls: this.data.img
    })
  },

  
  previewReply(e) {
    const url = e.currentTarget.dataset.url
    wx.previewImage({
      urls: url
    })
  },

  previewReply2(e) {
    const url = e.currentTarget.dataset.url
    const urlArr = new Array
    urlArr.push(url)
    wx.previewImage({
      urls: urlArr
    })
  },

  enterReplyDetail() {
    wx.setStorageSync('page', this.data.reply);
      
    wx.navigateTo({
      url: '../reply_detail/reply_detail',
    })
  }
})